package com.yiyukongjian.house;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TabHost;

import android.widget.RadioGroup.OnCheckedChangeListener;

@SuppressWarnings("deprecation")
public class Index extends TabActivity implements TabHost.TabContentFactory{

	private String mUserName;
	RadioGroup rg = null;
	private TabHost mTabHost;
	Intent intent = new Intent();
	Intent intent2 = new Intent();
	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);	
		setContentView(R.layout.main_tab);		
//		Bundle bundle=this.getIntent().getExtras();
//		mUserName=bundle.getString("LOGIN_USERNAME");
//		this.setTitle("hello  "+ mUserName);
		
		//初始化Table内容 
		intent.setClass(this, HouseInfoAdd.class);
		intent2.setClass(this, QueryConditionActivity.class);
	    mTabHost = getTabHost();
	    mTabHost.addTab(mTabHost.newTabSpec("radio_button0").setIndicator("radio_button0").setContent(this));
	    mTabHost.addTab(mTabHost.newTabSpec("radio_button1").setIndicator("radio_button1").setContent(intent));
	    mTabHost.addTab(mTabHost.newTabSpec("radio_button2").setIndicator("radio_button2").setContent(intent2));
	    mTabHost.setCurrentTabByTag("radio_button0");
		
		rg = (RadioGroup)findViewById(R.id.radio_group);
		rg.check(R.id.defaultButton);
		rg.setOnCheckedChangeListener(new OnCheckedChangeListener()
		{
			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				if(checkedId != -1)
				{
					RadioButton radioButton = (RadioButton)findViewById(checkedId);
					String tag = radioButton.getTag().toString();
					mTabHost.setCurrentTabByTag(tag);
				}
			}
        	
        });
	}
	@Override
	public View createTabContent(String tag){
        return LayoutInflater.from(this).inflate(R.layout.activity_index, null);
	}
	
}
